<%--
  Created by IntelliJ IDEA.
  User: 40167
  Date: 2023/12/2
  Time: 17:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<jsp:include page="head.jsp"></jsp:include>
<body>
<jsp:include page="navbar_head.jsp"></jsp:include>

<div class="container-fluid">
    <jsp:include page="navbar.jsp"></jsp:include>
    <div class="col-md-9">
        <div><h2 class="sub-header">放映厅列表</h2>
            <div class="text-right col-md-12">
                <a class="btn btn-primary " type="submit" href="${pageContext.request.contextPath}/admin/add_auditorium">新增放映厅</a>
            </div>

            <div class="table-responsive col-md-12">
                <table class="table table-striped table-bordered table-hover" id="auditorium-table">
                    <thead>
                    <tr style="background-color: #00b3ee">
                        <th class="text-center"><input type="checkbox" id="check_all"></th>
                        <th>放映厅名称</th>
                        <th>所属电影院</th>
                        <th>座位数</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:if test="${empty page.items}">
                        <tr>
                            <td colspan="7">未查询到相关数据!</td>
                        </tr>
                    </c:if>
                    <c:if test="${!empty page.items}">
                        <c:forEach var="auditorium" items="${page.items}">
                            <tr <c:if test="${auditorium.id eq queryedId}">style="background-color: #9acfea;"</c:if>>
                                <td class="text-center"><input type="checkbox" class="check_item"></td>
                                <td class="text-center">${auditorium.name}</td>
                                <td class="text-center">${auditorium.cinema.name}</td>
                                <td class="text-center">${auditorium.capacity}</td>
                                <td class="text-center">
                                    <div class="btn-group btn-group-md" role="group">
                                <span class="input-group-btn">
                                <button type="button" class="btn btn-primary modify_btn" modify_id="${auditorium.id}">
                                    <span class="glyphicon glyphicon-edit"> 修改</span>
                                </button>
                                <button type="button" class="btn btn-danger delete_btn" delete_id="${auditorium.id}">
                                    <span class="glyphicon glyphicon-remove"> 删除</span>
                                </button>
                                    <button type="button" class="btn btn-success delete_btn"
                                            query_id="${auditorium.id}">
                                    <span class="glyphicon glyphicon-eye-open"> 查看更多放映安排</span>
                                </button>
                                    </span>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    <input type="text" name="cinemaId" id="cinemaId" value="${auditorium.cinema.id}"
                           style="display: none">
                    </tbody>
                    <c:if test="${page.pageCount gt 0}">
                        <tfoot>
                        <tr>
                            <td colspan="7" class="text-center">
                                <ul class="nav nav-pills pull-left">
                                    <li id="goods_delete_batch_li">
                                        <a><span class="glyphicon glyphicon-remove"></span>批量删除</a>
                                    </li>
                                </ul>
                                <jsp:include page="page_nav.jsp"></jsp:include>
                            </td>
                        </tr>
                        </tfoot>
                    </c:if>
                    <c:if test="${!empty failMsg}">
                        <p class="bg-danger col-md-12" style="font-size: 20px;border-radius: 5px">${failMsg}</p>
                    </c:if>
                    <c:if test="${!empty msg}">
                        <p class="bg-warning" style="font-size: 20px;border-radius: 5px">${msg}</p>
                    </c:if>
                </table>
            </div>
        </div>
    </div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<jsp:include page="script.jsp"></jsp:include>
<script>
    $(function () {
        $('.delete_btn').click(function () {
            var delete_id = $(this).attr('delete_id');
            window.location.href = "${pageContext.request.contextPath}/admin/auditorium_delete?id=" + delete_id;
        })
        $('.modify_btn').click(function () {
            var modify_id = $(this).attr('modify_id');
            window.location.href = "${pageContext.request.contextPath}/admin/auditorium_modify?id=" + modify_id;
        })
        $("#check_all").click(function () {
            $(".check_item").prop("checked", $(this).prop("checked"));
        });
        $(".check_item").click(function () {
            var flag = $(".check_item").length == $(".check_item:checked").length;
            $("#check_all").prop("checked", flag);
        });
    });

</script>
</body>
</html>
